<template>
  <el-form class="add-event-packet" v-if="wbData">
    <dropdown-normal label="类型" :valLists="PACKET_TYPE" v-model="wbData.type" @change="onUpdateWbComponent"></dropdown-normal>
    <input-normal label="红包eid" v-model="wbData.eid" @change="onUpdateWbComponent"></input-normal>
    <input-normal label="短链" v-model="wbData.url" @change="onUpdateWbComponent"></input-normal>
    <input-normal label="gid" v-model="wbData.gid" @change="onUpdateWbComponent"></input-normal>
    <input-normal label="运营主体uid" v-model="wbData.send_uid" @change="onUpdateWbComponent"></input-normal>
    <el-form-item label="开始时间">
      <el-date-picker format="YYYY-MM-DD HH:mm:ss" v-model="wbData.starttime" type="datetime" placeholder="选择日期时间" @change="onUpdateWbComponent"></el-date-picker>
    </el-form-item>
    <el-form-item label="截止时间">
      <el-date-picker format="YYYY-MM-DD HH:mm:ss" v-model="wbData.endtime" type="datetime" placeholder="选择日期时间" @change="onUpdateWbComponent"></el-date-picker>
    </el-form-item>
    <input-normal label="签名" v-model="wbData.sign" @change="onUpdateWbComponent"></input-normal>
    <dropdown-normal label="是否发博" :valLists="PACKET_PUSH_TYPE" v-model="wbData.share" @change="onUpdateWbComponent"></dropdown-normal>
  </el-form>
</template>

<script setup lang="ts">
import { useWebControlsStore } from '@/store/web/controls'
import { PACKET_PUSH_TYPE, PACKET_TYPE } from '@/const/web/'

const props = defineProps<{ 
  event: IEvent,
  index: number,
}>()

const event = props.event
const useWebControls = useWebControlsStore()

let wbData_: any
const wbData = computed(() => {
  try {
    wbData_ = useWebControls.currentControls![event.controlId] && useWebControls.currentControls![event.controlId].data
  } catch (error) {
    console.log("controlData.data null")
  }
  return wbData_
})
const onUpdateWbComponent = () => {
  useWebControls.updateWbComponent({ controlId: event.controlId, data: wbData_ })
}
</script>